home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / pas_all.zip / TI204.ASC < prev    next >
Text File  |  1992-08-12  |  2KB  |  133 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.   PRODUCT : TURBO PASCAL                               NUMBER : 204
  10.   VERSION : 2.0xx
  11.        OS : PC-DOS, MS-DOS
  12.      DATE : April 1, 1986                                PAGE : 1/2
  13.     TITLE : RANDOM NUMBER SEED LOCATIONS
  14.  
  15.  
  16.  
  17.  
  18.   Turbo Pascal maintains a four byte random number seed. There is
  19.   a Randomize procedure to give that seed a random value which the
  20.   function, Random, then uses to generate random values within a
  21.   specified range.
  22.  
  23.   Random :  r := seed;
  24.  
  25.   The function Random(value) calls the following routine:
  26.  
  27.   function Random(N_Max): real;
  28.   var c1, c2, r : real;
  29.   begin
  30.     c1 := exp(32 * ln(2));
  31.     c2 := exp(16 * ln(2));
  32.     r  := (r * 129 * $361962E9) mod c1;
  33.     Random := r div c2 mod N_Max;
  34.   end;
  35.  
  36.   The following table gives the random number seed address for most
  37.   Turbo Pascal implementations:
  38.  
  39.   Random Number Seed Locations
  40.  
  41.     IBM TURBO.COM               0129
  42.     IBM TURBO-87.COM            0116
  43.     Generic TURBO.COM           0129
  44.     Generic TURBO-87.COM        0116
  45.  
  46.   The seed may be declared as:
  47.  
  48.     Var RandomSeed: Array [0..3] Of Byte Absolute DSeg:$0129;
  49.  
  50.   or:
  51.  
  52.     Var   RandomSeed: Array [0..1] Of Integer Absolute DSeg:$0129;
  53.  
  54.   By replacing the value in the address, you can seed the random  number
  55.   generator in any way you like: read it from a file; read a  number
  56.   from the user; ask for the user to hit a key, and count  until he
  57.   does; get the system time; or, assign a constant va
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.   PRODUCT : TURBO PASCAL                               NUMBER : 204
  76.   VERSION : 2.0xx
  77.        OS : PC-DOS, MS-DOS
  78.      DATE : April 1, 1986                                PAGE : 2/2
  79.     TITLE : RANDOM NUMBER SEED LOCATIONS
  80.  
  81.  
  82.  
  83.  
  84.   DISCLAIMER: You have the right to use this technical information
  85.   subject to the terms of the No-Nonsense License Statement that
  86.   you received with the Borland product to which this information
  87.   pertains.
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.